package com.fan.leetcode;

import java.util.Arrays;

/**
 * 645. 错误的集合
 *
 * @author ZhangFan
 * @since 2021/8/3 下午 10:24
 */
public class Question645 {
    public int[] findErrorNums(int[] nums) {
        Arrays.sort(nums);
        int[] arr = new int[2];
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] != i + 1) {
                arr[0] = i + 1;
            }
            if (nums[i] == nums[i + 1]) {
                arr[1] = nums[i];
            }
        }
        return arr;
    }
}
